#!/bin/bash

dirs='dir_dir dir_file'
dir2='dir_file'

for item in ${dirs}
do
    if [ -e ~/${item} ]; then
        echo "~/${item} 已存在！" 
    else
        mkdir ~/${item}
        echo "~/${item} 创建成功！"
    fi
done

echo "请输入一个目录，使用绝对路径："
read dirname
if [ ! -e ${dirname} ]; then
    echo "${dirname} 不存在，退出！"
    exit 1
fi
if [ ! -d ${dirname} ]; then
    echo "${dirname} 不是目录，退出！"
fi
for file in `ls ${dirname}`
do
    if [ -f ${dirname}/${file} ]; then
        cp ${dirname}/${file} ~/dir_file/
    else
        cp -Rf ${dirname}/${file} ~/dir_dir/
    fi
done
echo "文件复制成功，退出！"

